package src.Packets;

import src.Util.Stream;
import src.Players.*;
import src.Main;

public class ItemOption2
{
    public ItemOption2(Player p)
    {
        if(p == null || p.inStream == null)
        {
            return;
        }
        int interfaceId = p.inStream.readSignedWordBigEndianA();
        int itemId = p.inStream.readSignedWordBigEndianA();
        int itemIndex = p.inStream.readSignedWordBigEndian();
        switch(interfaceId)
        {
            case 5064: //bank item.
                if(p.interfaceId != 5292)
                {
                    p.frame.sendMessage(p, "Do not try and cheat!");
                    break;
                }
                Bank b = new Bank();
                b.bankItem(p, itemId, itemIndex, 5);
                b = null;
            break;
            case 5382: //Withdraw item from bank.
                if(p.interfaceId != 5292)
                {
                    p.frame.sendMessage(p, "Do not try and cheat!");
                    break;
                }
                b = new Bank();
                b.fromBank(p, itemId, itemIndex, 5);
                b = null;
            break;
            case 3823:
                if(p.interfaceId != 3824)
                {
                    p.frame.sendMessage(p, "Do not try and cheat!");
                    break;
                }
                if(Main.m.ge.item.isUntradable(itemId))
                {
                    p.frame.sendMessage(p, "You cannot sell this item.");
                    break;
                }
                Shop s = new Shop();
                s.sellItem(p, itemId, itemIndex, 1);
            break;
            case 3900:
                if(p.interfaceId != 3824)
                {
                    p.frame.sendMessage(p, "Do not try and cheat!");
                    break;
                }
                s = new Shop();
                s.buyItem(p, itemId, itemIndex, 1);
            break;
            default:
                Main.m.log("[" + p.playerIndex + "-" + p.username + "] Item option 1 " + interfaceId);
            break;
        }
    }
}